package com.tom.architect02.other.memory;

import android.os.Handler;
import android.os.Message;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import java.lang.ref.WeakReference;

/**
 * Added by Tom on 2024/03/15.
 */
public class MainActivity extends AppCompatActivity {



    private static class MyHandler extends Handler {
        private WeakReference<MainActivity> activityWeakReference;
        public MyHandler(MainActivity activity) {
            activityWeakReference = new WeakReference<>(activity);
        }

        @Override
        public void handleMessage(@NonNull Message msg) {
            MainActivity activity = activityWeakReference.get();
            if (activity != null)
                if (msg.what == 1)
                    ; //对应的逻辑处理
        }
    }

}


